package ru.inse.core.dao.dict.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import ru.inse.core.domain.dict.Place;
import ru.inse.core.domain.dict.PlaceType;


public class PlaceMapper
    implements RowMapper<Place>
{
    @Override
    public Place mapRow(ResultSet rs, int rowNum)
        throws SQLException
    {
        Place place = new Place();
        place.setId(rs.getLong("id"));
        place.setName(rs.getString("name"));
        place.setCityId(rs.getLong("city_id"));
        long placeTypeId = rs.getLong("place_type_id");
        place.setType(PlaceType.getById(placeTypeId));
        return place;
    }
}
